package com.cuit.riskassessment.service.impl;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cuit.riskassessment.dao.project.ProjectMapper;
import com.cuit.riskassessment.service.ProjectService;
import com.cuit.riskassessment.util.Tree;
import com.cuit.riskassessment.vo.Project;

@Service(value="projectService")
public class PojectServiceImpl implements ProjectService {

	@Autowired
	@Resource(name="projectMapper")
	private ProjectMapper projectMapper;
	
	@Override
	public boolean addProject(Project p) {
		// TODO Auto-generated method stub
		Integer id = this.projectMapper.getMaxId();
		id = (id==null)?2:id+2;
		p.setId(id);
		return this.projectMapper.addProject(p)>0?true:false;
	}

	@Override
	public boolean updateProject(Project p) {
		// TODO Auto-generated method stub
		return this.projectMapper.updateProject(p)>0?true:false;
	}

	@Override
	public boolean delProject(int id) {
		// TODO Auto-generated method stub
		return this.projectMapper.delProject(id)>0?true:false;
	}

	@Override
	public Tree getProject(Integer id) {
		// TODO Auto-generated method stub
		return this.projectMapper.getTreeByProjId(id);
	}

}
